<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css"
          href="css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="js/ckform.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <style type="text/css">
        body {
            font-size: 20px;
            padding-bottom: 40px;
            background-color: #e9e7ef;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media ( max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }
    </style>
	<%--提示消息插件--%>
    <script src="js/Dream-Msg/lib/dream-msg.min.js"></script>
    <script>
        $(function () {
            //一进来立即加载类别等信息
            getBtype();
        })
        //删除一级分类
        function deleteOneBtype(typeid,typename) {
            // alert(typeid+"---"+typename)
            if(confirm("你确定要删除【"+typename+"】吗?")){
                $.post("btype/deleteOneBtype/"+typeid,function (result) {
                    // alert(JSON.stringify(result))
                    if(result.status == 1){
                        //删除成功
                        Dreamer.success(result.message)
                        //刷新
                        getBtype();
                    }else{
                        Dreamer.error(result.message)
                    }
                })
            }
        }

        function getBtype() {
            $.post("btype/getBigType",function (result) {
                // alert(JSON.stringify(result))
                let typelist='';
                result.forEach(function(type){
                    let typetwolist='';
                    type.btypeList.forEach(function (typetwo) {
                        typetwolist +=`<option value="\${typetwo.typeid}">&nbsp;\${typetwo.typename}</option>`;
                    })
                    typelist+= `
                        <tr>
                            <td>\${type.typename}</td>
                            <td>\${type.typedes}</td>
                            <td>
                                <select>
                                       \${typetwolist}
                               </select>
                            </td>
                            <td>
                                <button type="submit"><a href="subtype_list.jsp?typeid=\${type.typeid}">管理小类</a></button>
                            </td>
                            <td>
                                <button type="submit"><a href="type_update.jsp?typeid=\${type.typeid}">修改</a></button>
                            </td>
                            <td>
                                <button type="submit" onclick="deleteOneBtype(\${type.typeid},'\${type.typename}')">删除</button>
                            </td>
                        </tr>
                    `;


                });
                $("#tbody").html(typelist)
            })
        }
    </script>
</head>
<body>
<form class="form-inline definewidth m20" action="#" method="get">
    <font color="#777777"><strong>大类信息：</strong></font>

</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
    <tr>
        <th>大类名称</th>
        <th>类别描述</th>
        <th>查看小类</th>
        <th>小类管理</th>
        <th>修改</th>
        <th>删除</th>
    </tr>
    </thead>
    <tbody id="tbody">
        <%--存放数据行--%>

    </tbody>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" id="addnew">
    <a href="type_add.jsp">添加大类</a>
</button>
</body>
</html>